package org.easy.chatai;


import com.alibaba.fastjson.JSON;
import org.easy.chatai.model.ChatModelRequest;
import org.easy.core.util.HttpUtil;
import org.easy.chatai.model.ChatModelResponse;
import lombok.extern.slf4j.Slf4j;

import java.util.HashMap;
import java.util.Map;

/**
 * 通用方法封装工具类
 */
@Slf4j
public class ChatAiClient {


    public ChatModelResponse chatBlocking(String url, String token, ChatModelRequest chatModelRequest) {
        Map<String, String> headers = new HashMap<>();
        headers.put("Authorization", "Bearer " + token);
        log.info("ssepostJsonCallback  {} {} {}", url, token, JSON.toJSONString(chatModelRequest));
        String response = HttpUtil.postJson(url, headers, chatModelRequest);
        return JSON.parseObject(response, ChatModelResponse.class);
    }
}